<h2 class="grid_12">
    Evento: <?php echo $eventopista['Evento']['nombre']; ?><br />
    Pista: <?php echo $eventopista['Pista']['nombre']; ?><br />
    Fecha: <?php echo $this->Utilidades->fechaes($eventopista['EventosPista']['fecha']); ?>
</h2>                                                                                
<div class="grid_8">
    <div class="box">
        <div class="header">
            <?php echo $this->Html->image('icons/packs/fugue/16x16/document--plus.png', array('width' => 16, 'height' => 16)); ?>            
            <h3>Listado de Pistas</h3>            
            <span></span>
        </div>
        <?php //comienza el contenido que quieres colocar ?>
        <div class="content">
            <?php echo $this->Form->create('CategoriaPista'); ?>
            <?php echo $this->Form->hidden('categoria_pista', array('value' => $id_eventopista)); ?>
            <table class="table" id="pistas">
                <thead>
                    <tr>                        
                        <th>Nombre</th>
                        <th>Rango</th>                         
                        <th>Seleccionar</th>
                    </tr>
                </thead>
                <tbody>
                    <?php //debug($categorias); ?>
                    <?php foreach ($categorias as $c): ?>
                        <?php $id = $c['Categoriaspista']['id']; ?>                        
                        <tr>                            
                            <td><?php echo $c['Categoriaspista']['nombre']; ?></td>                            
                            <td>
                                De <?php echo $c['Categoriaspista']['desde']; ?> hasta 
                                <?php echo $c['Categoriaspista']['hasta']; ?> meses
                            </td>                                                                                    
                            <td> 
                                <input name="check_<?php echo $id; ?>" id="check_<?php echo $id; ?>" type="checkbox" value="<?php echo $id; ?>" />
                                <?php echo $this->Form->hidden("pista_$id", array("id" => "pista_$id", 'value' => 0)); ?>
                            </td>
                        </tr>
                    <script>
                        $("#check_<?php echo $id; ?>").click(function(){
                            if($(this).is(":checked")) {
                                //$(".ck:checkbox:not(:checked)").attr("checked", "checked");
                                //alert($(this).val());
                                var valor_<?php echo $id; ?> = $(this).val();
                                $("#pista_<?php echo $id; ?>").val(valor_<?php echo $id; ?>);                                
                            }else{
                                //$(".ck:checkbox:checked").removeAttr("checked");
                                $("#pista_<?php echo $id; ?>").val("0");    
                            }
                        });
                    </script>
                <?php endforeach; ?>                    
                </tbody>   
            </table>   
            <div class="actions">
                <div class="actions-left">
                    <input type="reset" value="Limpiar" />
                </div>                
                <?php
                $options = array(
                    'label' => 'Registrar Pistas en Evento',
                    'div' => array(
                        'class' => 'actions-right',
                    )
                );
                echo $this->Form->end($options);
                ?>                
            </div>
            <script defer>
                $(window).load(function() {
                    $('#pistas').dataTable();
                    $(window).resize();
                });                
            </script>
        </div>
        <?php //fin del contenido a colocar   ?>
    </div> <!-- End of .box -->
</div> <!-- End of .grid_4 -->                                            
<div class="grid_4">
    <?php echo $this->element('menu_eventos'); ?>
</div> <!-- End of .grid_4 -->
<?php echo $this->element('js_tablas'); ?>
<?php echo $this->element('js_forms'); ?>
<!-- End of #main_content -->
<div class="push clear"></div>